package com.xxmw.transaction.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xxmw.transaction.common.entity.R;
import com.xxmw.transaction.common.utils.Assert;
import com.xxmw.transaction.model.app.VipRecord;
import com.xxmw.transaction.service.app.IVipRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: yamoo
 * @create: 2020-07-08 17:06
 */
@Slf4j
@RestController
@RequestMapping("admin/vipRecord")
public class AdminVipRecordController {

    @Autowired
    private IVipRecordService vipRecordService;

    @GetMapping
    public R list(@RequestParam(required = false, defaultValue = "1") Integer page,
                  @RequestParam(required = false, defaultValue = "20") Integer pageSize,
                  @RequestParam(required = false) String username){
        LambdaQueryWrapper<VipRecord> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Assert.isNotNullOrEmpty(username), VipRecord::getUsername, username);
        IPage<VipRecord> result = vipRecordService.page(new Page<>(page, pageSize), wrapper);
        return R.ok(result);
    }

}
